<?php
    require "common/clean-url.php";
    require 'config/primary-menu.php';
    
    
    if(!isset($_SESSION))
          session_start();

    
?>
<html>
    <head>
        <title><?php echo $config['site_name']; ?></title>
        <h1><?php echo $config['site_name'];?></h1>

        <script type="text/javascript" src="<?php echo $config['site_url'];?>/js/booking.js"></script>

    </head>
    <body>
        <div id="primary-menu">
            <ul>
             <?php   if(isset($_SESSION['user_id'])): //for login user
                    foreach($primary_menu[$_SESSION['description']] as $key=>$value):
             ?>
                        <li><a href="<?php echo $value;?>"> <?php echo $key; ?></a></li>
             <?php
                    endforeach;
                else: //anonymous
                    foreach($primary_menu['anonymous'] as $key=>$value):
             ?>
                        <li><a href="<?php echo $value;?>"> <?php echo $key; ?></a></li>
            <?php
                    endforeach;;
                endif;

             ?>
           </ul>
        </div>
        <div id="main-content">
          <?php
                switch (requestParam(1)){
/*.......................ajax implementation starts......................*/
                    case "ajx-accept-booking":
                            ob_clean();
                            $booking_id= requestParam(2);
                            echo "successfuly called ajax";
                            require 'BL/booking.php';
                            $bl= new Booking();
                            $bl->acceptBookingResquest($booking_id);

                        die();
                        break;
/*.......................ajax implementation ends......................*/
                    case "user":
                                if(isset($_SESSION['user_id']))
                                    require "PL/view-profile.php";
                                else
                                    require "PL/login.php";


                                break;
                    case "booking":

                                switch(requestParam(2)){
                                        case "regular":
                                            if($_SESSION['description']=="admin"):
                                                require "PL/booking-regular.php";
                                            else:
                                                require "PL/unauthorized.html";
                                            endif;

                                            break;
                                        case "request":
                                            if($_SESSION['description']=="admin"):
                                                require "PL/booking-request.php";
                                            else:
                                                require "PL/unauthorized.html";
                                            endif;

                                            break;
                                }

                        break;
                    case "login":
                        ob_start();
                        if(!isset($_SESSION['user_id'])):
                             require "PL/login.php";


        //                else:
        //                   header( 'Location:'.$config['site_url'] ) ;
                        endif;
                        break;
                    case "logout":
                        session_destroy();
                        header("location:".$config['site_url']);
                        break;
                    default : require "welcome-page.php";



                }




            ?>
            </div>



    </body>






</html>


